package com.leetcode.LC;

public class LC1556 {
    public String thousandSeparator(int n) {

        String s = String.valueOf(n);
        if (s.length() <= 3) {
            return s;
        }
        StringBuilder builder = new StringBuilder();
        int count = 0;
        for (int i = s.length() - 1; i >= 0; i--) {
            builder.append(s.charAt(i));
            count++;
            if (count != s.length() && count % 3 == 0) {
                builder.append('.');
            }
        }
        return builder.reverse().toString();
    }
}
